Ext.define('AmpleHarvest.objects.forms.irtCommon.classification',
{
	extend			: 'Ext.form.FieldSet',
	alias			: 'widget.ampleharvest-objects-forms-irtcommon-classification',
	title			: "Classification",
	collapsible		: false,
	labelWidth	: 70,
	width		: 620,
	height		: 185,
	boxMinWidth	: 620,
	boxMinHeight: 185,
	stateful		: false,
	listeners		: {},
	requires		:
		[
			"Ext.form.field.Text", 
			"Ext.form.FieldSet",
			'Ext.layout.container.VBox',
			'Ext.layout.container.HBox',
		],
	statics 		: {},
	
	setUnclassified : function()
	{
		//Disable radio buttons that don't apply.
		this.sciLevelVBox.getComponent("scilevel_radiocontainer").
				getComponent('scilevel_si').disable();
		
		//Enable proper radio buttons
		this.sciLevelVBox.getComponent("scilevel_radiocontainer").
				getComponent('scilevel_none').setValue(true);
				
		this.releaseLevelVBox.getComponent("releaselevel_radiocontainer").
				getComponent('releaselevel_fouo').setValue(true);	
	},
	
	/**
	 * This will be implemented to improve code.
	 * 
	setUnclassified : function(bool_unclassified)
	{
		//Disable radio buttons that don't apply.
		this.sciLevelVBox.getComponent("scilevel_radiocontainer").
				getComponent('scilevel_si').disable();
		
		//Enable proper radio buttons
		this.sciLevelVBox.getComponent("scilevel_radiocontainer").
				getComponent('scilevel_none').setValue(true);
				
		this.releaseLevelVBox.getComponent("releaselevel_radiocontainer").
				getComponent('releaselevel_fouo').setValue(true);	
	},
	
	setConfidential : function(bool_confidential){
	
	},
	setSecret : function(bool_secret){
		
	},
	setTopSecret : function(bool_topsecret){
		
	},
	*/
	
	setClassified : function()
	{
		this.sciLevelVBox.getComponent("scilevel_radiocontainer").
				getComponent('scilevel_si').enable();	
			
		this.sciLevelVBox.getComponent("scilevel_radiocontainer").
				getComponent('scilevel_si').enable();
				
		this.sciLevelVBox.getComponent("scilevel_radiocontainer").
				getComponent('scilevel_none').setValue(false);	
			
		this.sciLevelVBox.getComponent("scilevel_radiocontainer").
				getComponent('scilevel_si').setValue(false);
		
		this.releaseLevelVBox.getComponent("releaselevel_radiocontainer").
			getComponent('releaselevel_fvey').setValue(true);
	},

	initComponent	: function()
	{
		this.classificationHbox = Ext.create('Ext.Panel', 
		{ 
			border		: false,
			layout		: 
			{
				type	: 'hbox',
				align	: 'middle'
			}
		});	
		
	//-------------------- ACCESS LEVEL --------------------//
		this.accessLevel = Ext.create("Ext.form.FieldSet",
		{
			title		: "Access Level",
			collapsible	: false,
			labelWidth	: 70,
			boxMinHeight: 140,
			height		: 140,
			flex		: 1,
            itemId: 'accesslevel_fieldset'
		});
		
		this.accessLevelVBox = Ext.create('Ext.Panel', 
		{ 
			border		: false,
			layout		: 
			{
				type	: 'vbox',
				align	: 'left'
			},
			items: [
	        {
	            xtype			: 'checkboxgroup',
	            allowBlank: false,
	            defaultType		: 'radiofield',
	            defaults		: 
	            {
	                flex	: 1
	            },
	            layout: 'vbox',
	            itemId: 'accesslevel_VBox',
	            items: 
	            [
	                {
	                    boxLabel  : 'UNCLASSIFIED',
			            name: 'classification', //PHP Column label
	                    inputValue: 'unclassified',
	                    handler: function(checkbox, checked) {
	                		if(checked){
	                			this.up('ampleharvest-objects-forms-irtcommon-classification').setUnclassified();
	                		}
	                	}
	                },
	                {
	                    boxLabel  : 'CONFIDENTIAL',
			            name: 'classification', //PHP Column label
	                    inputValue: 'confidential',
	                    handler: function(checkbox, checked) {
	                		if(checked){
	                			this.up('ampleharvest-objects-forms-irtcommon-classification').setClassified();
	                		}
	                	}
	                },
	                {
	                    boxLabel  : 'SECRET',
			            name: 'classification', //PHP Column label
	                    inputValue: 'secret',
	                    handler: function(checkbox, checked) {
	                		if(checked){
	                			this.up('ampleharvest-objects-forms-irtcommon-classification').setClassified();
	                		}
	                	}
	                },
	                {
	                    boxLabel  : 'TOP SECRET',
			            name: 'classification', //PHP Column label
	                    inputValue: 'topsecret',
	                    handler: function(checkbox, checked) {
	                		if(checked){
	                			this.up('ampleharvest-objects-forms-irtcommon-classification').setClassified();
	                		}
	                	}
	                },
               ]
           }]
		});	
		
		this.accessLevel.add( this.accessLevelVBox );
		
	
	//-------------------- SCI LEVEL --------------------//
		this.sciLevel = Ext.create("Ext.form.FieldSet",
		{
			title		: "SCI",
			collapsible	: false,
			labelWidth	: 70,
			boxMinHeight: 140,
			height		: 140,
			flex		: 1,
            itemId: 'scilevel_fieldset'
		});
		
		this.sciLevelVBox = Ext.create('Ext.Panel', 
		{ 
			border: false,
			layout : 
			{
				type: 'vbox',
				align: 'left'
			},
            itemId: 'scilevel_VBox',
			items: [
	        {
	            xtype			: 'checkboxgroup',
	            allowBlank: false,
	            defaultType		: 'radiofield',
	            defaults		: 
	            {
	                flex	: 1
	            },
	            layout: 'vbox',
	            itemId: 'scilevel_radiocontainer',
	            items: 
	            [
	                {
	                    boxLabel  : 'NONE',
			            name: 'sci', //PHP Column label
	                    inputValue: 'none',
			            itemId: 'scilevel_none'
	                },
	                {
	                    boxLabel  : 'SI',
			            name: 'sci', //PHP Column label
	                    inputValue: 'si',
			            itemId: 'scilevel_si'
	                },
               ]
           }]
		});	
		
		this.sciLevel.add( this.sciLevelVBox );
	
	
	
	
	//-------------------- RELEASE LEVEL --------------------//
		this.releaseLevel = Ext.create("Ext.form.FieldSet",
		{
			title		: "Release",
			collapsible	: false,
			labelWidth	: 70,
			boxMinHeight: 140,
			height		: 140,
			flex		: 1,
            itemId: 'releaselevel_fieldset'
		});
		
		this.releaseLevelVBox = Ext.create('Ext.Panel', 
		{ 
			border: false,
			layout : 
			{
				type: 'vbox',
				align: 'left'
			},
            itemId: 'releaselevel_VBox',
			items: [
	        {
	            xtype : 'checkboxgroup',
//	            allowBlank : false,
	            defaultType		: 'radiofield',
	            defaults		: 
	            {
	                flex	: 1,
	                disabled : true
	            },
	            layout: 'vbox',
	            itemId: 'releaselevel_radiocontainer',
	            items: 
	            [
	                {
	                    boxLabel  : 'FOR OFFICIAL USE ONLY',
			            name: 'distro', //PHP Column label
	                    inputValue: 'fouo',
			            itemId	  : 'releaselevel_fouo'
	                },
	                {
	                    boxLabel  : 'REL TO USA, FVEY',
			            name: 'distro', //PHP Column label
	                    inputValue: 'fvey',
			            itemId	  : 'releaselevel_fvey'
	                },
               ]
           }]
		});	
		
		this.releaseLevel.add( this.releaseLevelVBox );
	
		this.classificationHbox.add( this.accessLevel );
		this.classificationHbox.add( this.sciLevel );
		this.classificationHbox.add( this.releaseLevel );
	
		this.items =
		[
		 this.classificationHbox
		]
	    this.callParent();
	}
	}
);